Ext.define('PJ.view.downloadqrcode.List', {
    extend: 'AM.default.DefaultList',
    requires: ['AM.default.DefaultSearchForm', 
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.jsonp.DefaultSubmitJsonp',
               'AM.default.jsonp.DefaultLoadJsonp'
               ],
   selModel: {
       selType: '',
       // 设置为只能通过复选框选中行
       checkOnly: true
   },
    initComponent: function(){
    	var me = this;
        me.columns = [{
            header: '培训班编号',
            dataIndex: 'tc.class_Num',
            width: 90,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '培训班名称',
            dataIndex: 'tc.class_Name',
            flex: 1,
            minWidth: 120,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '主办单位',
            dataIndex: 'tc.sponsor_Name',
            width: 120,
			renderer: function(value, metaData, record){
				metaData.tdAttr = 'data-qtip="' + value + '"';
				return value;
			}
        }, {
            header: '开班时间',
            dataIndex: 'tc.begin_Date',
            width: 90,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '结业时间',
            dataIndex: 'tc.end_Date',
            width: 90,
            renderer: function(value, metaData, record){
                return value;
            }
        }, {
            header: '已报人数',
            dataIndex: 'reportedNumber',
            width: 130,
            renderer: function(value, metaData, record){
            	return  value;
            }
        }/*, {
        	header: '二维码',
            dataIndex: 'registrationExplanation',
            width: 65,
            align: 'center',
            renderer: function(value, metaData, record){
            	metaData.tdAttr = 'classNum="' + record.get("q.classNum") + '" subjectTitle="' + record.get("t.className") + '"';
            	return '<span class="QRcodeIco" style="cursor: pointer;"></span> ';
            },
            listeners: {
	            click: function(g, clm){
	            	var subjectTitle = clm.getAttribute("subjectTitle");
            		Ext.create('AM.default.DefaultWindowView', {
            			title: '二维码',
            			width: 270,
            			height: 330,
            			grid: me,
            			classNum: clm.getAttribute("classNum"),
            			items: [{
            				html: '<div style="text-align: center;padding-top:10px;"><span color="#A9A9A9">' + subjectTitle + '</span></div><img src="./erweima/classErweima/班级ID.png" alt="二维码" style="width:255px;height:255px;padding:8px 20px 20px 20px;">'
            			}],
            			buttons: [{
            	            text: '下载',
            	            scope: this,
            	            handler: function(button, event){
            	                //var win = button.up('window');
            	            }
            	        }, {
            	            text: '取消',
            	            scope: this,
            	            handler: function(button, event){
            	                var win = button.up('window');
            	                win.close();
            	            }
            	        }]
            		}).show();
	            }
            }
        }*/,{
        	header: '二维码',
            dataIndex: 'registrationExplanation',
            width: 65,
            sortable: false,
            align: 'center',
            renderer: function(value, metaData, record){
            	metaData.tdAttr = 'classNum="' + record.get("t.classNum") + '" classId="' + record.get("classId") + '"';
            	return '<span class="QRcodeIco" style="cursor: pointer;"></span> ';
            },
            listeners: {
	            click: function(g, clm){
	            	var classId = clm.getAttribute("classId");
	            	var src = me.store.qrCodeUrl + "?classId=" + classId;
            		Ext.create('AM.default.DefaultWindowView', {
            			title: '二维码',
            			width: 600,
            			height: 580,
            			grid: me,
            			html: "<iframe src=\"" + src + "\" frameborder='0' style=\"width:100%;height:100%\"></iframe>",
            			/*
            			items: [{
            				html: '<div style="text-align: center;padding-top:10px;"><span color="#A9A9A9">' + subjectTitle + '</span></div><img src="./skin/red/images/QRcodegj.png" alt="二维码" style="width:255px;height:255px;padding:8px 20px 20px 20px;">'
            			}],
            			*/
            			buttons: [{
            	            text: '关闭',
            	            scope: this,
            	            handler: function(button, event){
            	                var win = button.up('window');
            	                win.close();
            	            }
            	        }]
            		}).show();
	            }
            }
        }];
        me.store = Ext.create('PJ.'+ prototype +'.downloadqrcode.List', {
            isLoad: false
        });
        this.loadType = gj_onlineLearning_constant.loadType;//加载方式
        me.callParent(arguments);
    },
    
    listeners: {
    	viewready: function(){
    		var me = this;
    		me.addDocked([{
    			dock: 'top',
    			xtype: "searchform",
    			columnCount: 3,
    			fieldDefaults: {
    				labelAlign: 'right',
    				labelWidth: 70
    			},
    			items: [{
    				xtype: "textfield",
    				fieldLabel: '培训班编号',
    				name: "searchClassNum",
    				maxLength: "50",
    				emptyText: "请输入培训班编号"
    			}, {
    				xtype: "textfield",
    				fieldLabel: '培训班名称',
    				name: "searchClassName",
    				maxLength: "20",
    				emptyText: "请输入培训班名称"
    			}, {
    				xtype: "textfield",
    				fieldLabel: '主办单位',
    				name: "searchSponsorName",
    				maxLength: "20",
    				emptyText: "请输入主办单位"
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '开班时间',
    				name: 'searchBeginDate',
    				id: 'searchQuestionnaireSDRQ',
    				vtype: 'startLessEndDate',
    				startLessEndDate: {
    					targetCmpId: 'searchQuestionnaireEDRQ',
    					isStart: true
    				},
    				emptyText: "请输入开班时间"
    			}, {
    				xtype: 'defaultDate',
    				fieldLabel: '结业时间',
    				name: 'searchEndDate',
    				id: 'searchQuestionnaireEDRQ',
    				vtype: 'startLessEndDate',
    				vtypeText: '结业时间不能早于开班时间！',
    				startLessEndDate: {
    					targetCmpId: 'searchQuestionnaireSDRQ',
    					isStart: false
    				},
    				emptyText: "请输入结业时间"
    			}],
    			grid: this
    		}]);
            var store = this.store;
            var params = store.proxy.extraParams;
            var newParams = {};
            Ext.apply(params, newParams);
            store.isLoad = true;
            store.load();
    		// 触发权限过滤事件
    		this.fireEvent("permission", this);
    	}
    }
});

